/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * IteratedPrisonerDilemmaGlobalParameters.java
 *
 * Created on 26/Dez/2011, 23:05:23
 */

package intopo.game.impl.ipd;

import intopo.game.gui.AbstractGlobalParametersComponent;

/**
 *
 * @author <a href="mailto:mariano.pedro@gmail.com">Pedro Mariano</a>
 *
 * @version 1.0 26/Dez/2011
 */
public class IteratedPrisonerDilemmaGlobalParameters
	extends AbstractGlobalParametersComponent
{

	/** Creates new form BeanForm */
	public IteratedPrisonerDilemmaGlobalParameters ()
	{
		initComponents();
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
    @SuppressWarnings("unchecked")
   // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
   private void initComponents() {
      java.awt.GridBagConstraints gridBagConstraints;

      panel = new javax.swing.JPanel();
      jLabel1 = new javax.swing.JLabel();
      numberBinsFormattedTextField = new javax.swing.JFormattedTextField();
      mutationPanel = new javax.swing.JPanel();
      jLabel2 = new javax.swing.JLabel();
      stdevProbFormattedTextField = new javax.swing.JFormattedTextField();

      setBorder(javax.swing.BorderFactory.createTitledBorder("global parameters"));
      setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));

      panel.setBorder(javax.swing.BorderFactory.createTitledBorder("strategy parameters"));
      panel.setLayout(new java.awt.BorderLayout());

      jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
      jLabel1.setText("Number of bins: ");
      panel.add(jLabel1, java.awt.BorderLayout.CENTER);

      numberBinsFormattedTextField.setColumns(5);
      numberBinsFormattedTextField.setValue(new Integer (3));
      numberBinsFormattedTextField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
            numberBinsFormattedTextFieldPropertyChange(evt);
         }
      });
      panel.add(numberBinsFormattedTextField, java.awt.BorderLayout.EAST);

      add(panel);

      mutationPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("mutation"));
      mutationPanel.setLayout(new java.awt.GridBagLayout());

      jLabel2.setText("Standard deviation probability cooperate: ");
      mutationPanel.add(jLabel2, new java.awt.GridBagConstraints());

      stdevProbFormattedTextField.setColumns(5);
      stdevProbFormattedTextField.setValue(new Float (IteratedPrisonerDilemmaProbabilisticStrategy.Parameters.probStddev));
      stdevProbFormattedTextField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
            stdevProbFormattedTextFieldPropertyChange(evt);
         }
      });
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 1;
      gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
      gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
      mutationPanel.add(stdevProbFormattedTextField, gridBagConstraints);

      add(mutationPanel);
   }// </editor-fold>//GEN-END:initComponents

	 private void stdevProbFormattedTextFieldPropertyChange (java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_stdevProbFormattedTextFieldPropertyChange
		if (evt.getPropertyName ().equals ("value")) {
			final float value = (Float) this.stdevProbFormattedTextField.getValue ();
			final boolean ok = (value >= 0);
			if (ok) {
				IteratedPrisonerDilemmaProbabilisticStrategy.Parameters.probStddev = value;
			}
			this.update (stdevProbFormattedTextField, ok);
		}
	 }//GEN-LAST:event_stdevProbFormattedTextFieldPropertyChange

	 private void numberBinsFormattedTextFieldPropertyChange (java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_numberBinsFormattedTextFieldPropertyChange
		if (evt.getPropertyName ().equals ("value")) {
			final int value = (Integer) this.numberBinsFormattedTextField.getValue ();
			final boolean ok = (value >= 0);
			if (ok) {
				IteratedPrisonerDilemmaProbabilisticStrategy.Parameters.probabilityBin = value;
			}
			this.update (numberBinsFormattedTextField, ok);
		}
	 }//GEN-LAST:event_numberBinsFormattedTextFieldPropertyChange


   // Variables declaration - do not modify//GEN-BEGIN:variables
   private javax.swing.JLabel jLabel1;
   private javax.swing.JLabel jLabel2;
   private javax.swing.JPanel mutationPanel;
   private javax.swing.JFormattedTextField numberBinsFormattedTextField;
   private javax.swing.JPanel panel;
   private javax.swing.JFormattedTextField stdevProbFormattedTextField;
   // End of variables declaration//GEN-END:variables

}

// Local Variables:
// mode: java
// mode: flyspell-prog
// ispell-local-dictionary: "british"
// End:
